﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Linq
{
    public static class IndexedEnumerableExtension
    {
        public static IEnumerable<IndexedItem<T>> AsIndexedEnumerable<T>(this IEnumerable<T> items, int startIndex = 0, int indexStep = 1)
        {
            int index = startIndex;
            foreach (var fo in items)
            {
                yield return new IndexedItem<T>(index, fo);
                index += indexStep;
            }
        }
    }

    public struct IndexedItem<T>
    {
        public IndexedItem(int index, T item)
        {
            this.Index = index;
            this.Item = item;
        }
        public readonly int Index;
        public readonly T Item;
    }
}
